home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 701-725 / 723 / printerctrl / source / printerctrl.c < prev    next >
C/C++ Source or Header  |  1995-03-18  |  29KB  |  1,585 lines

  1. // ------------------------------------------------------------------------
  2. //
  3. //  Printer Controller v1.00 (25.07.92)
  4. //                                                                          
  5. // ------------------------------------------------------------------------
  6. //
  7. //  Source: Amiga SAS/Lattice C 5.10b
  8. //  Written by: Paul Miskovsky, Toronto, Canada
  9. //
  10. //  UUCP: paul.miskovsky@canrem.com
  11. //
  12. //    Distributed as UnEmploymentWare (FreeWare), 1992
  13. //
  14. // ------------------------------------------------------------------------
  15.  
  16. // ---/ Revision History /-------------------------------------------------
  17. //
  18. //    Compile Options: LC -b1 -cfist -v -y -m0 -d0 -O <filename[.c]>
  19. //
  20. //    Linker Options: LIB:cback.o+<filename.o>+LIB:lreqglue.o
  21. //                    TO <filename> LIB LIB:lc.lib+LIB:amiga.lib SC SD ND
  22. //
  23. //    Debug Testing: ENFORCER: Not Tested - no MMU :(
  24. //                   MUNGWALL: PASSED
  25. //                   MEMWATCH: PASSED
  26. //
  27. //    Enviroment: Amiga A1000 (68010) w/512k + 1Meg Insider + A590w/2Meg
  28. //                20M Western Digital + 52M Quantum LPS + 44M SyQuest SQ555
  29. //
  30. //                AmigaDOS 1.3.2 (Kick 34.5   Work 34.34) - Development
  31. //                  AmigaDOS 2.04  (Kick 37.175 Work 37.67) - Testing
  32. //
  33. //                SAS/Lattice C 5.10b + CygnusEd Professional 2.12
  34. //
  35. //
  36. //  req.library © 1988/1989/1990 reserved by Colin Fox and Bruce Dawson
  37. //
  38. //
  39. //    July 25, 1992 - v1.00 First release.
  40. //
  41. //
  42.  
  43. // ---/ Includes /----------------------------------------------------------
  44.  
  45. #include <clib/intuition_protos.h>
  46. #include <clib/exec_protos.h>
  47. #include <clib/dos_protos.h>
  48.  
  49. #include <intuition/intuitionbase.h>
  50. #include <devices/parallel.h>
  51. #include <devices/printer.h>
  52. #include <exec/exec.h>
  53. #include <dos.h>
  54.  
  55. #include <string.h>
  56. #include <stdlib.h>
  57. #include <stdio.h>
  58.  
  59. #include <libraries/reqbase.h>
  60. #include <proto/req.h>
  61.  
  62.  
  63. // ---/ Defines /-----------------------------------------------------------
  64.  
  65. const int UNIT_NUMBER  = 0;
  66.  
  67. #define GLNODEFAULTB 0
  68. #define DSIZE 130
  69. #define FCHARS 30
  70.  
  71. #define PRINT 26
  72. #define STAT  25
  73. #define EXIT  24
  74. #define LINE  23
  75. #define HELP  22
  76. #define CMD   21
  77. #define HEX   20
  78. #define BELL  19
  79. #define SKIP  18
  80. #define JUST  17
  81. #define PROP  16
  82. #define RLF   15
  83. #define LF    14
  84. #define TOF   13
  85. #define DOUB  12
  86. #define SHAD  11
  87. #define ENLRG 10
  88. #define UNDER  9
  89. #define ITAL   8
  90. #define BOLD   7
  91. #define FELITE 6
  92. #define FPICA  5
  93. #define FNORM  4
  94. #define NLQ    3
  95. #define DRFT   2
  96. #define RST    1
  97.  
  98.  
  99. // ---/ Version /-----------------------------------------------------------
  100.  
  101. UBYTE *VersionTag = "\0$VER: PrinterCTRL v1.00 (25.07.92)";
  102.  
  103.  
  104. // ---/ Custom Function Prototypes /----------------------------------------
  105.  
  106. void Open_All( void );
  107. void Close_All( LONG, STRPTR );
  108.  
  109. void Menu_Analysis( SHORT, SHORT, SHORT );
  110. void RAW_Analysis( USHORT,USHORT );
  111. void Gadget_Analysis( USHORT );
  112.  
  113. LONG SetupPrinter( void );
  114. LONG OpenPrinter( union printerIO * );
  115. void ClosePrinter( union printerIO *);
  116. void DeletePrtReq( union printerIO *  );
  117.  
  118. LONG PrintPrtCommand( union printerIO *,LONG, UBYTE, UBYTE, UBYTE, UBYTE );
  119. LONG PrintPrtESCCommand( union printerIO *, UBYTE * );
  120. LONG PrintPrtRawString( union printerIO *, STRPTR );
  121. LONG PrintDevCommand( union printerIO *, UWORD );
  122.  
  123. UBYTE * GetNewWindowTitle( void );
  124. void CenterWindow( struct NewWindow * );
  125.  
  126. STRPTR MakeFileRequester( struct ReqFileRequester * );
  127. LONG ReqGetLong( struct GetLongStruct * );
  128.  
  129. LONG NewReqGetString( struct GetStringStruct * );
  130.  
  131. void ReqShowText( void );
  132. LONG PrintFile( union printerIO *, STRPTR );
  133.  
  134. LONG SetUpParallel( void );
  135. LONG OpenParallel( void );
  136. void CloseParallel( void );
  137. LONG StatusParallel( struct IOExtPar *, struct IntuiText * );
  138.  
  139.  
  140. // ---/ Function Prototypes /-----------------------------------------------
  141.  
  142. void _main( char * );
  143.  
  144. union printerIO * CreateExtIO( struct MsgPort *, USHORT );
  145. void DeleteExtIO( struct IORequest * );
  146.  
  147. struct MsgPort * CreatePort( STRPTR, USHORT );
  148. void DeletePort( struct MsgPort * );
  149.  
  150. union printerIO * CreatePrtReq( void );
  151.  
  152. void SimpleRequest( STRPTR,... );
  153. BOOL GetLong( struct GetLongStruct * );
  154.  
  155.  
  156. // ---/ Global Structures and Variables /-----------------------------------
  157.  
  158. struct IntuitionBase     *IntuitionBase     = NULL;
  159. struct GfxBase             *GfxBase         = NULL;
  160. struct ReqLib            *ReqBase        = NULL;
  161. struct Window             *mywin1            = NULL;
  162. struct RastPort         *rp             = NULL;
  163.  
  164. struct Gadget            *GadgetIAddress = NULL;
  165.  
  166. struct MsgPort            *winport        = NULL;
  167. struct MsgPort             *prtport        = NULL;
  168. union  printerIO        *printerReq;
  169.  
  170. struct MsgPort  *ParallelMP = NULL;
  171. struct IOExtPar *ParallelIO = NULL;
  172.  
  173. struct ReqFileRequester filereq;
  174. struct GetLongStruct getlong;
  175. struct GetStringStruct getnewstring;
  176. struct TRStructure textreq;
  177.  
  178. struct IntuiText status;
  179.  
  180. UBYTE titlearray[40];
  181. LONG numbers[10];
  182. LONG result;
  183.  
  184. LONG ParallelError;
  185. LONG PrinterError;
  186.  
  187. union printerIO
  188.     {
  189.     struct IOStdReq        ios;
  190.     struct IODRPReq        iodrp;
  191.     struct IOPrtCmdReq    iopc;
  192. };
  193.  
  194.  
  195. // ---/ Resident Variables (cback.o) /--------------------------------------
  196.  
  197. LONG _stack = 4000L;
  198. char *_procname = "PrinterCTRL";
  199. LONG _priority = 0L;
  200. LONG _BackGroundIO = 0L;
  201.  
  202.  
  203. // ---/ Power Windows Generated Source /------------------------------------
  204.  
  205. SHORT BorderVectors1[] = {
  206.     0,0,
  207.     42,0,
  208.     42,10,
  209.     0,10,
  210.     0,0
  211. };
  212.  
  213. struct Border Border1 = {
  214.     -1,-1,
  215.     1,0,JAM1,
  216.     5,
  217.     BorderVectors1,
  218.     NULL
  219. };
  220.  
  221. SHORT BorderVectors2[] = {
  222.     0,0,
  223.     363,0,
  224.     363,10,
  225.     0,10,
  226.     0,0
  227. };
  228.  
  229. struct Border Border2 = {
  230.     -1,-1,
  231.     1,0,JAM1,
  232.     5,
  233.     BorderVectors2,
  234.     NULL
  235. };
  236.  
  237. struct TextAttr TOPAZ80 = {
  238.     (STRPTR)"topaz.font",
  239.     TOPAZ_EIGHTY,0,0
  240. };
  241.  
  242. struct IntuiText IText0 = {
  243.     3,0,JAM1,
  244.     100,1,
  245.     &TOPAZ80,
  246.     "SEND FILE TO PRINTER",
  247.     NULL
  248. };
  249.  
  250. struct Gadget Gadget26 = {
  251.     NULL,
  252.     6,60,
  253.     362,9,
  254.     NULL,
  255.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  256.     BOOLGADGET,
  257.     (APTR)&Border2,
  258.     NULL,
  259.     &IText0,
  260.     NULL,
  261.     NULL,
  262.     26,
  263.     NULL
  264. };
  265.  
  266. struct Gadget Gadget25 = {
  267.     &Gadget26,
  268.     6,48,
  269.     362,9,
  270.     NULL,
  271.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  272.     BOOLGADGET,
  273.     (APTR)&Border2,
  274.     NULL,
  275.     NULL,
  276.     NULL,
  277.     NULL,
  278.     25,
  279.     NULL
  280. };
  281.  
  282. struct IntuiText IText1 = {
  283.     3,0,JAM1,
  284.     5,1,
  285.     &TOPAZ80,
  286.     "EXIT",
  287.     NULL
  288. };
  289.  
  290. struct Gadget Gadget24 = {
  291.     &Gadget25,
  292.     327,36,
  293.     41,9,
  294.     NULL,
  295.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  296.     BOOLGADGET,
  297.     (APTR)&Border1,
  298.     NULL,
  299.     &IText1,
  300.     NULL,
  301.     NULL,
  302.     24,
  303.     NULL
  304. };
  305.  
  306. struct IntuiText IText2 = {
  307.     1,0,JAM1,
  308.     5,1,
  309.     &TOPAZ80,
  310.     "LINE",
  311.     NULL
  312. };
  313.  
  314. struct Gadget Gadget23 = {
  315.     &Gadget24,
  316.     327,24,
  317.     41,9,
  318.     NULL,
  319.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  320.     BOOLGADGET,
  321.     (APTR)&Border1,
  322.     NULL,
  323.     &IText2,
  324.     NULL,
  325.     NULL,
  326.     23,
  327.     NULL
  328. };
  329.  
  330. struct IntuiText IText3 = {
  331.     2,0,JAM1,
  332.     5,1,
  333.     &TOPAZ80,
  334.     "HELP",
  335.     NULL
  336. };
  337.  
  338. struct Gadget Gadget22 = {
  339.     &Gadget23,
  340.     327,12,
  341.     41,9,
  342.     NULL,
  343.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  344.     BOOLGADGET,
  345.     (APTR)&Border1,
  346.     NULL,
  347.     &IText3,
  348.     NULL,
  349.     NULL,
  350.     22,
  351.     NULL
  352. };
  353.  
  354. struct IntuiText IText4 = {
  355.     1,0,JAM1,
  356.     9,1,
  357.     &TOPAZ80,
  358.     "CMD",
  359.     NULL
  360. };
  361.  
  362. struct Gadget Gadget21 = {
  363.     &Gadget22,
  364.     282,36,
  365.     41,9,
  366.     NULL,
  367.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  368.     BOOLGADGET,
  369.     (APTR)&Border1,
  370.     NULL,
  371.     &IText4,
  372.     NULL,
  373.     NULL,
  374.     21,
  375.     NULL
  376. };
  377.  
  378. struct IntuiText IText5 = {
  379.     1,0,JAM1,
  380.     9,1,
  381.     &TOPAZ80,
  382.     "HEX",
  383.     NULL
  384. };
  385.  
  386. struct Gadget Gadget20 = {
  387.     &Gadget21,
  388.     282,24,
  389.     41,9,
  390.     NULL,
  391.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  392.     BOOLGADGET,
  393.     (APTR)&Border1,
  394.     NULL,
  395.     &IText5,
  396.     NULL,
  397.     NULL,
  398.     20,
  399.     NULL
  400. };
  401.  
  402. struct IntuiText IText6 = {
  403.     1,0,JAM1,
  404.     5,1,
  405.     &TOPAZ80,
  406.     "BELL",
  407.     NULL
  408. };
  409.  
  410. struct Gadget Gadget19 = {
  411.     &Gadget20,
  412.     282,12,
  413.     41,9,
  414.     NULL,   
  415.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  416.     BOOLGADGET,
  417.     (APTR)&Border1,
  418.     NULL,
  419.     &IText6,
  420.     NULL,
  421.     NULL,
  422.     19,
  423.     NULL
  424. };
  425.  
  426. struct IntuiText IText7 = {
  427.     3,0,JAM1,
  428.     5,1,
  429.     &TOPAZ80,
  430.     "SKIP",
  431.     NULL
  432. };
  433.  
  434. struct Gadget Gadget18 = {
  435.     &Gadget19,
  436.     236,36,
  437.     41,9,
  438.     NULL,
  439.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  440.     BOOLGADGET,
  441.     (APTR)&Border1,
  442.     NULL,
  443.     &IText7,
  444.     NULL,
  445.     NULL,
  446.     18,
  447.     NULL
  448. };
  449.  
  450. struct IntuiText IText8 = {
  451.     3,0,JAM1,
  452.     5,1,
  453.     &TOPAZ80,
  454.     "JUST",
  455.     NULL
  456. };
  457.  
  458. struct Gadget Gadget17 = {
  459.     &Gadget18,
  460.     236,24,
  461.     41,9,
  462.     NULL,
  463.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  464.     BOOLGADGET,
  465.     (APTR)&Border1,
  466.     NULL,
  467.     &IText8,
  468.     NULL,
  469.     NULL,
  470.     17,
  471.     NULL
  472. };
  473.  
  474. struct IntuiText IText9 = {
  475.     3,0,JAM1,
  476.     5,1,
  477.     &TOPAZ80,
  478.     "PROP",
  479.     NULL
  480. };
  481.  
  482. struct Gadget Gadget16 = {
  483.     &Gadget17,
  484.     236,12,
  485.     41,9,
  486.     NULL,
  487.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  488.     BOOLGADGET,
  489.     (APTR)&Border1,
  490.     NULL,
  491.     &IText9,
  492.     NULL,
  493.     NULL,
  494.     16,
  495.     NULL
  496. };
  497.  
  498. struct IntuiText IText10 = {
  499.     1,0,JAM1,
  500.     9,1,
  501.     &TOPAZ80,
  502.     "RLF",
  503.     NULL
  504. };
  505.  
  506. struct Gadget Gadget15 = {
  507.     &Gadget16,
  508.     190,36,
  509.     41,9,
  510.     NULL,
  511.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  512.     BOOLGADGET,
  513.     (APTR)&Border1,
  514.     NULL,
  515.     &IText10,
  516.     NULL,
  517.     NULL,
  518.     15,
  519.     NULL
  520. };
  521.  
  522. struct IntuiText IText11 = {
  523.     1,0,JAM1,
  524.     5,1,
  525.     &TOPAZ80,
  526.     " LF",
  527.     NULL
  528. };
  529.  
  530. struct Gadget Gadget14 = {
  531.     &Gadget15,
  532.     190,24,
  533.     41,9,
  534.     NULL,
  535.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  536.     BOOLGADGET,
  537.     (APTR)&Border1,
  538.     NULL,
  539.     &IText11,
  540.     NULL,
  541.     NULL,
  542.     14,
  543.     NULL
  544. };
  545.  
  546. struct IntuiText IText12 = {
  547.     1,0,JAM1,
  548.     8,1,
  549.     &TOPAZ80,
  550.     "TOF",
  551.     NULL
  552. };
  553.  
  554. struct Gadget Gadget13 = {
  555.     &Gadget14,
  556.     190,12,
  557.     41,9,
  558.     NULL,
  559.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  560.     BOOLGADGET,
  561.     (APTR)&Border1,
  562.     NULL,
  563.     &IText12,
  564.     NULL,
  565.     NULL,
  566.     13,
  567.     NULL
  568. };
  569.  
  570. struct IntuiText IText13 = {
  571.     3,0,JAM1,
  572.     5,1,
  573.     NULL,
  574.     "DOUB",
  575.     NULL
  576. };
  577.  
  578. struct Gadget Gadget12 = {
  579.     &Gadget13,
  580.     144,36,
  581.     41,9,
  582.     NULL,
  583.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  584.     BOOLGADGET,
  585.     (APTR)&Border1,
  586.     NULL,
  587.     &IText13,
  588.     NULL,
  589.     NULL,
  590.     12,
  591.     NULL
  592. };
  593.  
  594. struct IntuiText IText14 = {
  595.     3,0,JAM1,
  596.     5,1,
  597.     &TOPAZ80,
  598.     "SHAD",
  599.     NULL
  600. };
  601.  
  602. struct Gadget Gadget11 = {
  603.     &Gadget12,
  604.     144,24,
  605.     41,9,
  606.     NULL,
  607.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  608.     BOOLGADGET,
  609.     (APTR)&Border1,
  610.     NULL,
  611.     &IText14,
  612.     NULL,
  613.     NULL,
  614.     11,
  615.     NULL
  616. };
  617.  
  618. struct IntuiText IText15 = {
  619.     3,0,JAM1,
  620.     1,1,
  621.     &TOPAZ80,
  622.     "ENLRG",
  623.     NULL
  624. };
  625.  
  626. struct Gadget Gadget10 = {
  627.     &Gadget11,
  628.     144,12,
  629.     41,9,
  630.     NULL,
  631.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  632.     BOOLGADGET,
  633.     (APTR)&Border1,
  634.     NULL,
  635.     &IText15,
  636.     NULL,
  637.     NULL,
  638.     10,
  639.     NULL
  640. };
  641.  
  642. struct IntuiText IText16 = {
  643.     3,0,JAM1,
  644.     0,1,
  645.     NULL,
  646.     "UNDER",
  647.     NULL
  648. };
  649.  
  650. struct Gadget Gadget9 = {
  651.     &Gadget10,
  652.     98,36,
  653.     41,9,
  654.     NULL,
  655.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  656.     BOOLGADGET,
  657.     (APTR)&Border1,
  658.     NULL,
  659.     &IText16,
  660.     NULL,
  661.     NULL,
  662.     9,
  663.     NULL
  664. };
  665.  
  666. struct IntuiText IText17 = {
  667.     3,0,JAM1,
  668.     5,1,
  669.     &TOPAZ80,
  670.     "ITAL",
  671.     NULL
  672. };
  673.  
  674. struct Gadget Gadget8 = {
  675.     &Gadget9,
  676.     98,24,
  677.     41,9,
  678.     NULL,
  679.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  680.     BOOLGADGET,
  681.     (APTR)&Border1,
  682.     NULL,
  683.     &IText17,
  684.     NULL,
  685.     NULL,
  686.     8,
  687.     NULL
  688. };
  689.  
  690. struct IntuiText IText18 = {
  691.     3,0,JAM1,
  692.     5,1,
  693.     &TOPAZ80,
  694.     "BOLD",
  695.     NULL
  696. };
  697.  
  698. struct Gadget Gadget7 = {
  699.     &Gadget8,
  700.     98,12,
  701.     41,9,
  702.     NULL,
  703.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  704.     BOOLGADGET,
  705.     (APTR)&Border1,
  706.     NULL,
  707.     &IText18,
  708.     NULL,
  709.     NULL,
  710.     7,
  711.     NULL
  712. };
  713.  
  714. struct IntuiText IText19 = {
  715.     3,0,JAM1,
  716.     1,1,
  717.     NULL,
  718.     "ELITE",
  719.     NULL
  720. };
  721.  
  722. struct Gadget Gadget6 = {
  723.     &Gadget7,
  724.     52,36,
  725.     41,9,
  726.     NULL,
  727.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  728.     BOOLGADGET,
  729.     (APTR)&Border1,
  730.     NULL,
  731.     &IText19,
  732.     NULL,
  733.     NULL,
  734.     6,
  735.     NULL
  736. };
  737.  
  738. struct IntuiText IText20 = {
  739.     3,0,JAM1,
  740.     5,1,
  741.     &TOPAZ80,
  742.     "PICA",
  743.     NULL
  744. };
  745.  
  746. struct Gadget Gadget5 = {
  747.     &Gadget6,
  748.     52,24,
  749.     41,9,
  750.     NULL,
  751.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  752.     BOOLGADGET,
  753.     (APTR)&Border1,
  754.     NULL,
  755.     &IText20,
  756.     NULL,
  757.     NULL,
  758.     5,
  759.     NULL
  760. };
  761.  
  762. struct IntuiText IText21 = {
  763.     3,0,JAM1,
  764.     5,1,
  765.     &TOPAZ80,
  766.     "NORM",
  767.     NULL
  768. };
  769.  
  770. struct Gadget Gadget4 = {
  771.     &Gadget5,
  772.     52,12,
  773.     41,9,
  774.     NULL,
  775.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  776.     BOOLGADGET,
  777.     (APTR)&Border1,
  778.     NULL,
  779.     &IText21,
  780.     NULL,
  781.     NULL,
  782.     4,
  783.     NULL
  784. };
  785.  
  786. struct IntuiText IText22 = {
  787.     2,0,JAM1,
  788.     9,1,
  789.     NULL,
  790.     "NLQ",
  791.     NULL
  792. };
  793.  
  794. struct Gadget Gadget3 = {
  795.     &Gadget4,
  796.     6,36,
  797.     41,9,
  798.     NULL,
  799.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  800.     BOOLGADGET,
  801.     (APTR)&Border1,
  802.     NULL,
  803.     &IText22,
  804.     NULL,
  805.     NULL,
  806.     3,
  807.     NULL
  808. };
  809.  
  810. struct IntuiText IText23 = {
  811.     2,0,JAM1,
  812.     5,1,
  813.     NULL,
  814.     "DRFT",
  815.     NULL
  816. };
  817.  
  818. struct Gadget Gadget2 = {
  819.     &Gadget3,
  820.     6,24,
  821.     41,9,
  822.     NULL,
  823.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  824.     BOOLGADGET,
  825.     (APTR)&Border1,
  826.     NULL,
  827.     &IText23,
  828.     NULL,
  829.     NULL,
  830.     2,
  831.     NULL
  832. };
  833.  
  834. struct IntuiText IText24 = {
  835.     1,0,JAM1,
  836.     9,1,
  837.     &TOPAZ80,
  838.     "RST",
  839.     NULL
  840. };
  841.  
  842. struct Gadget Gadget1 = {
  843.     &Gadget2,
  844.     6,12,
  845.     41,9,
  846.     NULL,
  847.     RELVERIFY+GADGIMMEDIATE+STRINGCENTER,
  848.     BOOLGADGET,
  849.     (APTR)&Border1,
  850.     NULL,
  851.     &IText24,
  852.     NULL,
  853.     NULL,
  854.     1,
  855.     NULL
  856. };
  857.  
  858. struct Menu mymenu = {
  859.     NULL,
  860.     0,0,
  861.     0,0,
  862.     MENUENABLED,
  863.     (BYTE *)
  864.     "PrinterCTRL v1.00 (25.07.92) by Paul Miskovsky, Toronto, Canada.",
  865.     NULL
  866. };
  867.  
  868. struct NewWindow mynewwin1 = {
  869.     NULL,NULL,
  870.     374,72,
  871.     0,1,
  872.     GADGETDOWN+GADGETUP+NEWPREFS+CLOSEWINDOW,
  873.     WINDOWDRAG+WINDOWDEPTH+WINDOWCLOSE+ACTIVATE+NOCAREREFRESH,
  874.     &Gadget1,
  875.     NULL,
  876.     (UBYTE *)"Printer CTRL v1.00",
  877.     NULL,
  878.     NULL,
  879.     5,5,
  880.     -1,-1,
  881.     WBENCHSCREEN
  882. };
  883.  
  884.  
  885. // ---/ Main /-------------------------------------------------------------- 
  886.  
  887. void _main( cmdline )
  888. char *cmdline;
  889. {
  890. struct IntuiMessage *imsg;
  891. ULONG imsgClass;
  892. UWORD imsgCode;
  893.  
  894.     Open_All();
  895.  
  896.     for(;;)
  897.         {
  898.         if((imsg = (struct IntuiMessage *)
  899.             GetMsg(mywin1->UserPort)) == 0L)
  900.                 {
  901.                  Wait(1L << mywin1->UserPort->mp_SigBit);
  902.                  continue;
  903.             }
  904.  
  905.         imsgClass = imsg->Class;
  906.         imsgCode  = imsg->Code;
  907.  
  908.         ReplyMsg((struct Message *) imsg);
  909.  
  910.             switch(imsgClass)
  911.                 {
  912.                 case CLOSEWINDOW:
  913.                     Close_All(0L, NULL);
  914.                     break;
  915.  
  916.                 case MENUPICK:
  917.                     if(MENUNUM(imsgCode) != MENUNULL)
  918.                     Menu_Analysis(MENUNUM(imsgCode),
  919.                                    ITEMNUM(imsgCode),
  920.                                   SUBNUM(imsgCode));
  921.                     break;
  922.  
  923.                 case GADGETUP:
  924.  
  925.                     GadgetIAddress = (struct Gadget *) imsg->IAddress;
  926.                     Gadget_Analysis(GadgetIAddress->GadgetID);
  927.                     break;
  928.  
  929.                 default:
  930.                     break;
  931.             }
  932.     }
  933. }
  934.  
  935.  
  936. // ---/ Subroutines /-------------------------------------------------------
  937.  
  938. void Menu_Analysis(Menu, Item, SubItem)
  939. SHORT Menu,Item,SubItem;
  940.     {
  941.     switch(Menu)
  942.         {
  943.         case 0:
  944.             switch(Item)
  945.                 {
  946.                 case 0:
  947.                     Close_All(0L,NULL);
  948.                     break;
  949.  
  950.                 default:
  951.                     break;
  952.                 }
  953.  
  954.         default:
  955.             break;
  956.     }
  957. }
  958.  
  959.  
  960. void Gadget_Analysis( gadgetid )
  961. USHORT gadgetid;
  962.     {
  963.     STRPTR temp="",code="       ";
  964.     UBYTE *longnum;
  965.     SHORT n=0;
  966.  
  967.     if(!(ParallelError = OpenParallel()));
  968.         {
  969.         result = StatusParallel(ParallelIO,&status);
  970.         CloseParallel();
  971.     }
  972.  
  973.     if(PrinterError = OpenPrinter(printerReq));
  974.         {
  975.         switch(gadgetid)
  976.             {
  977.             case EXIT:
  978.                 ClosePrinter(printerReq);
  979.                 Close_All(0L,NULL);
  980.  
  981.             case LINE:
  982.                 result = PrintPrtCommand(printerReq,aRIN,0,0,0,0);
  983.                 strcpy(code,"aRIN");
  984.                 break;
  985.  
  986.             case HELP:
  987.                 ReqShowText();
  988.                 strcpy(code,"HELP");
  989.                 break;
  990.  
  991.             case CMD:
  992.                 result = PrintPrtCommand(printerReq,(LONG)ReqGetLong(&getlong),0,0,0,0);
  993.                 strcpy(code,"CMD#");
  994.                 break;
  995.  
  996.             case HEX:
  997.                 result = NewReqGetString(&getnewstring);
  998.                 longnum = (APTR)malloc(sizeof(char)*36);
  999.  
  1000.                 while(numbers[n])
  1001.                     {
  1002.                     sprintf(longnum,"%s%c",longnum,(UBYTE)numbers[n++]);
  1003.                 }
  1004.                 result = PrintPrtESCCommand(printerReq,longnum);
  1005.                 strcpy(code,"ESC#");
  1006.  
  1007.                 free(longnum);
  1008.                   break;
  1009.  
  1010.             case BELL:
  1011.                 result = PrintPrtESCCommand(printerReq,"\x07");
  1012.                 strcpy(code,"ESCx07");
  1013.                 break;
  1014.  
  1015.             case SKIP:
  1016.                 result = PrintPrtCommand(printerReq,aPERF,0,0,0,0);
  1017.                 strcpy(code,"aPERF");
  1018.                 break;
  1019.  
  1020.             case JUST:
  1021.                 result = PrintPrtCommand(printerReq,aJFY6,1,0,0,0);
  1022.                 strcpy(code,"aJFY6");
  1023.                 break;
  1024.  
  1025.             case PROP:
  1026.                 result = PrintPrtCommand(printerReq,aPROP2,0,0,0,0);
  1027.                 strcpy(code,"aPROP2");
  1028.                 break;
  1029.  
  1030.             case RLF:
  1031.                 result = PrintPrtCommand(printerReq,aRI,0,0,0,0);
  1032.                 strcpy(code,"aRI");
  1033.                 break;
  1034.  
  1035.             case LF:
  1036.                 result = PrintPrtCommand(printerReq,aNEL,0,0,0,0);
  1037.                 strcpy(code,"aNEL");
  1038.                 break;
  1039.  
  1040.             case TOF:
  1041.                 result = PrintPrtESCCommand(printerReq,"\x0C"); 
  1042.                 strcpy(code,"ESCx0C");
  1043.                 break;
  1044.  
  1045.             case DOUB:
  1046.                 result = PrintPrtCommand(printerReq,aDEN4,0,0,0,0);
  1047.                 strcpy(code,"aDEN4");
  1048.                 break;
  1049.  
  1050.             case SHAD:
  1051.                 result = PrintPrtCommand(printerReq,aDEN6,0,0,0,0);
  1052.                 strcpy(code,"aDEN6");
  1053.                 break;
  1054.  
  1055.             case ENLRG:
  1056.                 result = PrintPrtCommand(printerReq,aSHORP6,0,0,0,0);
  1057.                 strcpy(code,"aSHORP6");
  1058.                 break;
  1059.  
  1060.             case UNDER:
  1061.                 result = PrintPrtCommand(printerReq,aSGR4,0,0,0,0);
  1062.                 strcpy(code,"aSGR4");
  1063.                 break;
  1064.  
  1065.             case ITAL:
  1066.                 result = PrintPrtCommand(printerReq,aSGR3,0,0,0,0);
  1067.                 strcpy(code,"aSGR3");
  1068.                 break;
  1069.  
  1070.             case BOLD:
  1071.                 result = PrintPrtCommand(printerReq,aSGR1,0,0,0,0);
  1072.                 strcpy(code,"aSGR1");
  1073.                 break;
  1074.                 
  1075.             case FELITE:
  1076.                 result = PrintPrtCommand(printerReq,aSHORP2,0,0,0,0);
  1077.                 strcpy(code,"aSHORP2");
  1078.                 break;
  1079.  
  1080.             case FPICA:
  1081.                 result = PrintPrtCommand(printerReq,aSHORP4,0,0,0,0);
  1082.                 strcpy(code,"aSHORP4");
  1083.                 break;
  1084.  
  1085.             case FNORM:
  1086.                 result = PrintPrtCommand(printerReq,aSHORP0,0,0,0,0);
  1087.                 strcpy(code,"aSHORP0");
  1088.                 break;
  1089.  
  1090.             case NLQ:
  1091.                 result = PrintPrtCommand(printerReq,aDEN2,0,0,0,0);
  1092.                 strcpy(code,"aDEN2");
  1093.                 break;
  1094.  
  1095.             case DRFT:
  1096.                 result = PrintPrtCommand(printerReq,aSGR0,0,0,0,0);
  1097.                 strcpy(code,"aSGR0");
  1098.                 break;
  1099.  
  1100.             case RST:
  1101.                 result = PrintPrtCommand(printerReq,aRIS,0,0,0,0);
  1102.                 strcpy(code,"aRIS");
  1103.                 break;
  1104.  
  1105.             case STAT:
  1106.                 strcpy(code,"STATUS");
  1107.                 break;
  1108.  
  1109.             case PRINT:
  1110.                 strcpy(temp,MakeFileRequester(&filereq));
  1111.                 result = PrintFile(printerReq,temp);
  1112.                 strcpy(code,"PRINT");
  1113.                 break;
  1114.  
  1115.             default:
  1116.                 break;
  1117.         }
  1118.     ClosePrinter(printerReq);
  1119.     }
  1120.  
  1121.     temp = (char *)malloc(sizeof(char)*41);
  1122.  
  1123.     if(result)
  1124.         sprintf(temp,"%s - %s ERROR!",titlearray,code);
  1125.     else
  1126.         sprintf(temp,"%s - %s OK!",titlearray,code);
  1127.  
  1128.     SetWindowTitles(mywin1,temp,(UBYTE *) ~0);
  1129.     RefreshWindowFrame(mywin1);
  1130.  
  1131.     free(temp);
  1132. }
  1133.  
  1134.  
  1135. void Open_All( void )
  1136.     {
  1137.     if(!(GfxBase = (struct GfxBase *) OpenLibrary("graphics.library", 33L)))
  1138.         Close_All(20L, "\nRequires at least V33 Graphics.library\n");
  1139.  
  1140.     if(!(IntuitionBase = (struct IntuitionBase *) OpenLibrary("intuition.library", 33L)))
  1141.         Close_All(20L, "\nRequires at least V33 Intuition.library\n");
  1142.  
  1143.     if(!(ReqBase = (struct ReqLib *) OpenLibrary("req.library", 0L)))
  1144.         Close_All(20L, "\nRequires at least V2.x req.library\n");
  1145.  
  1146.     strcpy(mynewwin1.Title,GetNewWindowTitle());
  1147.  
  1148.     CenterWindow( &mynewwin1 );
  1149.  
  1150.     if(!(mywin1 = (struct Window *) OpenWindow(&mynewwin1)))
  1151.         Close_All(20L, "\nCouldn't open window\n");
  1152.  
  1153.     SetMenuStrip(mywin1,&mymenu);
  1154.  
  1155.     rp = mywin1->RPort;
  1156.  
  1157.     if(SetupPrinter() != NULL)
  1158.         Close_All(20L, "\nCouldn't setup printer PORT\n");
  1159.  
  1160.     if(SetUpParallel() != NULL)
  1161.            Close_All(20L, "\nCouldn't setup parallel PORT\n");
  1162.  
  1163.     if(!(ParallelError = OpenParallel()));
  1164.         {
  1165.         StatusParallel(ParallelIO,&status);
  1166.         CloseParallel();
  1167.     }
  1168. }
  1169.  
  1170.  
  1171. void Close_All( code,text )
  1172. LONG code;
  1173. STRPTR text;
  1174.     {
  1175. //  if(ParallelError == NULL) CloseDevice((struct IOReqest *) ParallelIO);
  1176.     if(ParallelIO) DeleteExtIO((struct IORequest *) ParallelIO);
  1177.     if(ParallelMP) DeletePort(ParallelMP);
  1178.  
  1179. //    if(PrinterError == NULL) CloseDevice((struct IOReqest *) printerReq);
  1180.     if(printerReq) DeletePrtReq(printerReq);
  1181.  
  1182.     if(ReqBase != NULL) PurgeFiles(&filereq);
  1183.  
  1184.     ClearMenuStrip(mywin1);
  1185.     if(mywin1!= NULL) CloseWindow(mywin1);
  1186.  
  1187.        if((IntuitionBase)!=NULL) CloseLibrary((struct Library *) IntuitionBase);
  1188.        if((GfxBase)!=NULL) CloseLibrary((struct Library *) GfxBase);
  1189.        if((ReqBase)!=NULL) CloseLibrary((struct Library *) ReqBase);
  1190.  
  1191. //  if(text) SimpleRequest(text);
  1192.        exit(code);
  1193. }
  1194.  
  1195.  
  1196. union printerIO *CreatePrtReq( void )
  1197.     {
  1198.     struct MsgPort *prtport;
  1199.     union printerIO *request;
  1200.  
  1201.     if(!(prtport = (struct MsgPort *) CreatePort("PrinterPORT",0)))
  1202.         Close_All(20L, "\nUnable to Create Printer PORT\n");
  1203.  
  1204.     if(!(request=(union printerIO *)
  1205.                  CreateExtIO(prtport,sizeof(union printerIO))))
  1206.         {
  1207.         DeletePort(prtport);
  1208.         Close_All(20L, "\nUnable to create ExtIO on Printer PORT\n");
  1209.     }
  1210.     return(request);
  1211. }
  1212.  
  1213.  
  1214. LONG SetupPrinter( void )
  1215.     {
  1216.     printerReq = ((union printerIO *) CreatePrtReq());
  1217.     return(0L);
  1218. }
  1219.  
  1220.  
  1221. void DeletePrtReq( request )
  1222. union printerIO *request;
  1223.     {
  1224.     struct MsgPort *prtport;
  1225.  
  1226.     prtport = request->ios.io_Message.mn_ReplyPort;
  1227.     DeleteExtIO((struct IORequest *) request);
  1228.     DeletePort(prtport);
  1229. }
  1230.  
  1231.  
  1232. LONG OpenPrinter( request )
  1233. union printerIO *request;
  1234.     {
  1235.     if(PrinterError = (OpenDevice("printer.device",NULL,
  1236.         (struct IORequest *) request, NULL)) != NULL)
  1237.         {
  1238.         textreq.Text          = "Printer did not open!";
  1239. //      textreq.Controls      = NULL;
  1240.         textreq.Window        = mywin1;
  1241.         textreq.NegativeText  = "Abort";
  1242.         textreq.Title         = "Error!";
  1243.         textreq.Timeout       = 60;
  1244.         textreq.versionnumber = REQVERSION;
  1245.         textreq.blockcolor    = 2;
  1246.  
  1247.         result = TextRequest(&textreq);
  1248.         return(1L);
  1249.     }
  1250.     else return(0L);
  1251. }
  1252.  
  1253.  
  1254. void ClosePrinter( request )
  1255. union printerIO *request;
  1256.     {
  1257.     if(PrinterError == NULL) CloseDevice((struct IOReqest *) printerReq);
  1258. }
  1259.  
  1260.  
  1261. LONG PrintPrtCommand( request, command, p0, p1, p2, p3 )
  1262. union printerIO *request;
  1263. LONG command;
  1264. UBYTE p0,p1,p2,p3;
  1265.     {
  1266.     request->iopc.io_Command     = PRD_PRTCOMMAND;
  1267.     request->iopc.io_PrtCommand = (UWORD)command;
  1268.     request->iopc.io_Parm0        = p0;
  1269.     request->iopc.io_Parm1        = p1;
  1270.     request->iopc.io_Parm2        = p2;
  1271.     request->iopc.io_Parm3        = p3;
  1272.  
  1273.     return(LONG)(DoIO((struct IORequest *) request));
  1274. }
  1275.  
  1276.  
  1277. LONG PrintPrtESCCommand( request, buffer )
  1278. union printerIO *request;
  1279. UBYTE *buffer;
  1280.     {
  1281.     request->ios.io_Command     = PRD_RAWWRITE;
  1282.     request->ios.io_Data        = (APTR)buffer;
  1283.     request->ios.io_Length        = strlen(buffer)+1;
  1284.  
  1285.     return(LONG)(DoIO((struct IORequest *) request));
  1286. }
  1287.  
  1288.  
  1289. LONG PrintPrtRawString( request, buffer )
  1290. union printerIO *request;
  1291. STRPTR buffer;
  1292.     {
  1293.     request->ios.io_Command     = PRD_RAWWRITE;
  1294.     request->ios.io_Data        = buffer;
  1295.     request->ios.io_Length        = strlen(buffer);
  1296.  
  1297.     return(LONG)(DoIO((struct IORequest *) request));
  1298. }
  1299.  
  1300.  
  1301. LONG PrintDevCommand( request, devcommand )
  1302. union printerIO *request;
  1303. UWORD devcommand;
  1304.     {
  1305.     request->ios.io_Command = devcommand;
  1306.     return(LONG)(DoIO((struct IORequest *) request));
  1307. }
  1308.  
  1309.  
  1310. UBYTE * GetNewWindowTitle( void )
  1311.     {
  1312.     struct Preferences *prefs, *prefsbuffer;
  1313.     UBYTE type[5];
  1314.  
  1315.     prefsbuffer = AllocMem((sizeof(struct Preferences)),MEMF_CHIP);
  1316.     prefs = GetPrefs(prefsbuffer,sizeof(struct Preferences));
  1317.  
  1318.     if( prefs->PrinterPort == PARALLEL_PRINTER ) strcpy(type,"PAR:");
  1319.     else strcpy(type,"SER:");
  1320.  
  1321.     sprintf(titlearray,"%s%s",type,prefs->PrinterFilename);
  1322.     FreeMem(prefsbuffer,sizeof(struct Preferences));
  1323.  
  1324.     return(titlearray);
  1325. }
  1326.  
  1327.  
  1328. void CenterWindow( pnewwin )
  1329. struct NewWindow *pnewwin;
  1330.     {
  1331.     pnewwin->LeftEdge =
  1332.         ((IntuitionBase->ActiveScreen->Width-pnewwin->Width)/2);
  1333.  
  1334.     pnewwin->TopEdge =
  1335.         ((IntuitionBase->ActiveScreen->Height-pnewwin->Height)/2);
  1336. }
  1337.  
  1338.  
  1339. STRPTR MakeFileRequester( requester )
  1340. struct ReqFileRequester *requester;
  1341.     {
  1342.     char answerarray[DSIZE+FCHARS] = "";
  1343.     char directoryname[DSIZE] = "";
  1344.     char filename[FCHARS] = "";
  1345.  
  1346.     answerarray[0] = 0;
  1347.  
  1348.     requester->Title = "Select File to Print";
  1349.     requester->PathName = answerarray;
  1350.     requester->Dir = directoryname;
  1351.     requester->File = filename;
  1352.  
  1353.     strcpy(requester->Hide,"*.info");
  1354.     strcpy(requester->Show,"*");
  1355.  
  1356.     requester->Flags = FRQCACHINGM | FRQINFOGADGETM | FRQLOADINGM;
  1357.     requester->dirnamescolor = 2;
  1358.     requester->devicenamescolor = 2;
  1359.  
  1360.     if(FileRequester( requester )) return(answerarray);
  1361. }
  1362.  
  1363.  
  1364. LONG ReqGetLong( getlongnum )
  1365. struct GetLongStruct *getlongnum;
  1366.     {
  1367.        getlongnum->titlebar = "Enter Driver CMD";
  1368.     getlongnum->defaultval      = NULL;
  1369.     getlongnum->minlimit        = NULL;
  1370.     getlongnum->maxlimit        = 255L;
  1371.     getlongnum->window          = NULL;
  1372.     getlongnum->versionnumber   = REQVERSION;
  1373.     getlongnum->flags           = NULL;
  1374.     getlongnum->rfu2            = NULL;
  1375.   
  1376.     if(GetLong(getlongnum)) return(getlongnum->result);
  1377. }
  1378.  
  1379.  
  1380. LONG NewReqGetString( getstring )
  1381. struct GetStringStruct *getstring;
  1382.     {
  1383.     STRPTR token,ptemp,stemp,res;
  1384.     USHORT n=0;
  1385.  
  1386.     result = 1L;
  1387.  
  1388.     ptemp = (STRPTR)malloc(sizeof(char)*36);
  1389.     stemp = (STRPTR)malloc(sizeof(char)*36);
  1390.  
  1391.     getstring->titlebar      = "Enter Code(s) in HEX";
  1392.     getstring->stringbuffer  = stemp;
  1393.     getstring->window        = NULL;
  1394.     getstring->stringsize    = 35;
  1395.     getstring->visiblesize   = 35;
  1396.     getstring->versionnumber = REQVERSION;
  1397.     getstring->flags         = NULL;
  1398.     getstring->rfu1          = NULL;
  1399.     getstring->rfu2          = NULL;
  1400.     getstring->rfu3          = NULL;
  1401.  
  1402.     if(NewGetString(getstring))
  1403.         {
  1404.         strcpy(ptemp,getstring->stringbuffer);
  1405.         result = 0L;
  1406.     }
  1407.  
  1408.     token = strtok(ptemp,", ");
  1409.     numbers[n++] = strtol(token,&res,16);
  1410.  
  1411.     while(token != NULL)
  1412.         {
  1413.         token = strtok(NULL,", ");
  1414.         numbers[n++] = strtol(token,&res,16);
  1415.     }
  1416.    
  1417.     free(ptemp);
  1418.     free(stemp);
  1419.  
  1420.     return(result);
  1421. }
  1422.  
  1423.  
  1424. void ReqShowText( void )
  1425.     {
  1426.     SimpleRequest( "PrinterCTRL 1.00 (25.07.92)        HELP\n\n"
  1427.                    " Read the original documentation for a \n"
  1428.                    " complete description of all functions \n"
  1429.                    " and features." );
  1430.     }
  1431.  
  1432.  
  1433. LONG PrintFile( request, file )
  1434. union printerIO *request;
  1435. STRPTR file;
  1436.     {
  1437.     struct FileInfoBlock info;
  1438.     APTR buffer;
  1439.     BPTR fh1;
  1440.  
  1441.     if((dfind(&info,file,0)) != NULL)
  1442.         {
  1443.         textreq.Text          = " File was not found! ";
  1444. //      textreq.Controls      = control;
  1445.         textreq.Window        = NULL;
  1446.         textreq.NegativeText  = "Resume";
  1447.         textreq.Title         = "Error!";
  1448.         textreq.Timeout       = 5;
  1449.         textreq.textcolor     = 1;
  1450.         textreq.detailcolor   = 2;
  1451.         textreq.blockcolor    = 1;
  1452.         textreq.versionnumber = REQVERSION;
  1453.  
  1454.         result = TextRequest(&textreq);
  1455.         return(1L);
  1456.     }
  1457.  
  1458.     if((fh1=(BPTR)Open(file,MODE_OLDFILE)) == NULL)
  1459.         {    
  1460.         textreq.Text          = " File could not be opened! ";
  1461. //      textreq.Controls      = control;
  1462.         textreq.Window        = NULL;
  1463.         textreq.NegativeText  = "Resume";
  1464.         textreq.Title         = "Error!";
  1465.         textreq.Timeout       = 5;
  1466.         textreq.textcolor     = 1;
  1467.         textreq.detailcolor   = 2;
  1468.         textreq.blockcolor    = 1;
  1469.         textreq.versionnumber = REQVERSION;
  1470.  
  1471.         result = TextRequest(&textreq);
  1472.         return(1L);
  1473.     }
  1474.  
  1475.     if((buffer=AllocMem(info.fib_Size,MEMF_FAST|MEMF_CLEAR)) == NULL)
  1476.        buffer=AllocMem(info.fib_Size,MEMF_CHIP|MEMF_CLEAR);
  1477.  
  1478.     if(buffer == NULL)
  1479.         {
  1480.         textreq.Text          = " Could not AllocMem required memory. ";
  1481. //      textreq.Controls      = control;
  1482.         textreq.Window        = NULL;
  1483.         textreq.NegativeText  = "Resume";
  1484.         textreq.Title         = "Error!";
  1485.         textreq.Timeout       = 5;
  1486.         textreq.textcolor     = 1;
  1487.         textreq.detailcolor   = 2;
  1488.         textreq.blockcolor    = 1;
  1489.         textreq.versionnumber = REQVERSION;
  1490.  
  1491.         result = TextRequest(&textreq);
  1492.         return(1L);
  1493.     }
  1494.  
  1495.     if((Read((BPTR)fh1,buffer,info.fib_Size)) != NULL)
  1496.         {
  1497.         request->ios.io_Command     = CMD_WRITE;
  1498.         request->ios.io_Data        = buffer;
  1499.         request->ios.io_Length        = info.fib_Size;
  1500.  
  1501.         result = DoIO((struct IORequest *) request);
  1502.     }
  1503.     FreeMem(buffer,info.fib_Size);
  1504.     Close((BPTR)fh1);
  1505.  
  1506.     return(result);
  1507. }
  1508.  
  1509.  
  1510. LONG SetUpParallel( void )
  1511.     {
  1512.     if(ParallelMP=(struct MsgPort *)CreatePort(0,0))
  1513.         {
  1514.         if(ParallelIO=(struct IOExtPar *)
  1515.             CreateExtIO(ParallelMP,sizeof(struct IOExtPar)))
  1516.             {
  1517.             ParallelIO->io_ParFlags = PARF_SHARED;
  1518.             return(0L);
  1519.         }
  1520.     }
  1521.     else return(1L);
  1522. }
  1523.  
  1524.  
  1525. LONG OpenParallel( void )
  1526.     {
  1527.     if(ParallelError = (OpenDevice(PARALLELNAME,UNIT_NUMBER,
  1528.         (struct IORequest *) ParallelIO,0) != 0))
  1529.         {
  1530.         return(1L);
  1531.     }
  1532.     else return(0L);
  1533. }
  1534.  
  1535.  
  1536. void CloseParallel( void )
  1537.     {
  1538.     if(ParallelError == NULL) CloseDevice((struct IOReqest *) ParallelIO);
  1539. }
  1540.  
  1541.  
  1542. LONG StatusParallel( parallel, itext )
  1543. struct IOExtPar *parallel;
  1544. struct IntuiText *itext;
  1545.     {
  1546.     char text[45] = "";
  1547.     int command;
  1548.  
  1549.     command = parallel->IOPar.io_Command;
  1550.     parallel->IOPar.io_Command = PDCMD_QUERY;
  1551.  
  1552.     result = (DoIO((struct IORequest *)parallel));
  1553.  
  1554.     strcpy(text," PAR:STATUS -");
  1555.  
  1556.     if(parallel->io_Status & IOPTF_PARBUSY) strcat(text," BUSY");
  1557.         else strcat(text," READY");
  1558.  
  1559.     if(parallel->io_Status & IOPTF_PAPEROUT) strcat(text," NO_PAPER");
  1560.         else strcat(text," PAPER_OK");
  1561.  
  1562.     if(parallel->io_Status & IOPTF_PARSEL) strcat(text," ONLINE");
  1563.         else strcat(text," OFFLINE");
  1564.  
  1565.     if(command == CMD_READ) strcat(text," INPUT");
  1566.         else strcat(text," OUTPUT");
  1567.  
  1568.         parallel->IOPar.io_Command = command;
  1569.  
  1570.         itext->FrontPen = 1;
  1571.         itext->BackPen = 0;
  1572.         itext->DrawMode = JAM2;
  1573.         itext->ITextFont = &TOPAZ80;
  1574.         itext->NextText = NULL;
  1575.  
  1576.         itext->IText = (UBYTE *)text;
  1577.  
  1578.         PrintIText(rp,itext,11L,49L);
  1579.  
  1580.     return(result);
  1581. }
  1582.  
  1583.  
  1584. // ---/ End /---------------------------------------------------------------
  1585.